package longcaisuyun.longcai.com.net;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import longcaisuyun.longcai.com.suyunbean.QiangDanItem;

/**
 * Created by Administrator on 2016/4/22.
 */
@HttpInlet(Net.QIANGDAN)
public class PostQiangList extends WHAsyPost<PostQiangList.Info> {
    public String driverid;
    public String point = "45.7669076120,126.6245708254";
    public String orderid;
    public PostQiangList(String driverid, String orderid, AsyCallBack asyCallBack) {
        super(asyCallBack);
        this.driverid = driverid;
        this.orderid=orderid;
    }

    @Override
    protected Info parser(JSONObject object) {
        Info info = new Info();
        try {
            info.message = object.getString("message");
            if (info.message.equals("1")) {
                for (int j = 0; j < object.getJSONArray("list").length(); j++) {
                    QiangDanItem qiangDanItem = new QiangDanItem();
                    qiangDanItem.uid = object.getJSONArray("list").getJSONObject(j).getString("uid");
                    qiangDanItem.setTime(object.getJSONArray("list").getJSONObject(j).getString("time"));
                    qiangDanItem.setAccount(object.getJSONArray("list").getJSONObject(j).getString("account"));
                    qiangDanItem.setIsbackorder(object.getJSONArray("list").getJSONObject(j).getString("isbackorder"));
                    qiangDanItem.setIsmove(object.getJSONArray("list").getJSONObject(j).getString("ismove"));
                    qiangDanItem.setDingdannum(object.getJSONArray("list").getJSONObject(j).getString("orderid"));
                    qiangDanItem.setOrdertype(object.getJSONArray("list").getJSONObject(j).getString("ordertype"));
                    qiangDanItem.setPostposttime(object.getJSONArray("list").getJSONObject(j).getString("posttime"));
                    qiangDanItem.setUsetime(object.getJSONArray("list").getJSONObject(j).getString("usetime"));
                    qiangDanItem.setWeek(object.getJSONArray("list").getJSONObject(j).getString("week"));
                    qiangDanItem.setTip(object.getJSONArray("list").getJSONObject(j).getString("tip"));
                    qiangDanItem.setReward(object.getJSONArray("list").getJSONObject(j).getString("reward"));
                    qiangDanItem.setIsmove(object.getJSONArray("list").getJSONObject(j).getString("ismove"));
                    qiangDanItem.setSaycontent(object.getJSONArray("list").getJSONObject(j).getString("saycontent"));
                    qiangDanItem.setOrdernumber(object.getJSONArray("list").getJSONObject(j).getString("ordernumber"));
                    qiangDanItem.setShi(object.getJSONArray("list").getJSONObject(j).getJSONArray("addresslist").getJSONObject(0).getString("address"));
                    qiangDanItem.setZhong(object.getJSONArray("list").getJSONObject(j).getJSONArray("addresslist").getJSONObject(object.getJSONArray("list").getJSONObject(j).getJSONArray("addresslist").length() - 1).getString("address"));
                    qiangDanItem.setJili(object.getJSONArray("list").getJSONObject(j).getString("juli"));
                    info.list.add(qiangDanItem);
                }
                return info;
            }
        } catch (JSONException e) {
            e.printStackTrace();
            return null;
        }
        return null;
    }
    public static class Info {
        public String message = "";
        public List<QiangDanItem> list = new ArrayList<>();
    }
}
